package com.pds.mvc;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ActionForward {
	 private String key = "";  
	    private boolean isDirect = true;  
	    /*************************************************************************** 
	     *  
	     * @param key 
	     *            取得跳转页面的url 
	     * @param isDirect 
	     *            是否要跳转并传递参数 
	     */  
	    public ActionForward(String key, boolean isDirect)  
	    {  
	        this.key = key;  
	        this.isDirect = isDirect;  
	    }  
	 
	
	    public void forward(HttpServletRequest request, HttpServletResponse response)  
	            throws ServletException, IOException  
	    {  
	       
	   
	        // 此处的key的值由execute中得到  
	        String jspUrl = null;  
	        if (null != key && !"".equals(key.trim()))  
	        {  
	            jspUrl = key;  
	        } else  
	        {  
	            jspUrl = "fail.jsp";  
	        }  
	        // 是否要跳转  
	        if (!isDirect)  
	        {  
	            response.sendRedirect(jspUrl);  
	        } else  
	        {  
	            request.getRequestDispatcher(jspUrl).forward(request, response);  
	        }  
	    }  
}
